Finally tagless observable recursion for an abstract grammar model
نویسندگان
چکیده
We define a finally tagless, shallow embedding of a typed grammar language. In order to avoid the limitations of traditional parser combinator libraries (no bottom-up parsing, no full grammar analysis or transformation), we require object-language recursion to be observable in the meta-language. Since existing proposals for recursive constructs are not fully satisfactory, we propose new finally tagless primitive recursive constructs to solve the problem. To do this in a well-typed way, we require considerable infrastructure, for which we reuse techniques from the multirec generic programming library. Our infrastructure allows a precise model of the complex interaction between a grammar, a parsing algorithm and a set of semantic actions. On the flip side, our approach requires the grammar author to provide a typeand value-level encoding of the grammar’s domain and we can provide only a limited form of constructs like many . We demonstrate five meta-language grammar algorithms exploiting our model, including a grammar pretty-printer, a reachability analysis, a translation of quantified recursive constructs to the standard one and an implementation of the left-corner grammar transform. The work we present forms the basis of the grammar-combinators parsing library, which is the first to work with a precise, shallow model of abstract context-free grammars in a classical (not dependently typed) functional language and which supports a wide range of grammar manipulation primitives. From a more general point of view, our work shows a solution to the well-studied problem of observable sharing in shallowly embedded domain-specific languages and specifically in finally tagless domain-specific languages.
منابع مشابه
Engineering Transformations of At - tributed Grammars in
An abstract representation for grammar rules that permits an easy implementation of several attributed grammar transformations is presented. It clearly separates the actions that contribute to evaluating attribute values from the circulation of these values, and it makes it easy to combine the representations of several rules in order to build the representation of new rules. This abstract form...
متن کاملEliminating Dead Computations on Recursive Data
This paper describes a general and e ective method for backward dependence analysis in the presence of recursive data constructions. The goal is to identify partially dead recursive data and eliminate dead computations on them. The method uses projections based on general regular tree grammars extended with the notion of live and dead, and de nes the analysis as mutually recursive grammar trans...
متن کاملTowards Applying Mona in Abstract Regular Tree Model Checking
We consider the problem of automated formal verification of modern concurrent software systems. Dealing with such systems, which involves handling unbounded dynamic instantiation, recursion, etc., naturally leads to a need of dealing with infinite state spaces. We suppose states of such systems to be encoded terms with a tree structure and we would like to use the abstract regular tree model ch...
متن کاملIntegrating Multithreading into the Spineless Tagless G-machine
To reduce the adverse effects of long latency communication operations in distributed implementations of the Spineless Tagless G-machine (STGM), a variant of the original abstract machine that contains explicit support for multithreading is introduced. In particular, source-to-source transformations can be used on the level of the abstract machine code to foster the tolerance to long latency co...
متن کاملHierarchical Statistical Semantic Realization for Minimal Recursion Semantics
We introduce a robust statistical approach to realization from Minimal Recursion Semantics representations. The approach treats realization as a translation problem, transforming the Dependency MRS graph representation to a surface string. Translation is based on a Synchronous Context-Free Grammar that is automatically extracted from a large corpus of parsed sentences. We have evaluated the new...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
- J. Funct. Program.
دوره 22 شماره
صفحات -
تاریخ انتشار 2012